﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Web.Mvc;
using System.Collections.Generic;
using Gman.Entity.Entities;
using Gman.WebApp.ServiceControllers;
using Gman.WebApp.Models;

namespace Gman.WebApp.Models
{
    public class TransferenciaActivoModel : BaseModel
    {
        public OperacionServiceController service = new OperacionServiceController();

        public ValidationBase Validator { get; set; }
        public List<KeyValuePair<String, String>> ValidationList = new List<KeyValuePair<string, string>>();
        public List<KeyValuePair<String, bool>> PropertyVisibilityList = new List<KeyValuePair<string, bool>>();

        public Guid? ID { get; set; }
        public String Action { get; set; }
        public TransferenciaActivosBE TransActivo { get; private set; }
        public ToolBarModel ToolBar { get; set; }

        public List<TransferenciaActivoDetalleModel> TransActivoDetalles { get; set; }
        public SelectList PersonalGestiona { get; private set; }
        public SelectList PersonalResponsable { get; private set; }

        PersonalBE personal = new PersonalBE();

        public List<TransferenciaActivoDetalleModel> toDelete { get; set; }

        public TransferenciaActivoModel()
        {
            TransActivo = new TransferenciaActivosBE();
            ID = Guid.NewGuid();

            PersonalGestiona = listaPersonal();
            PersonalResponsable = listaPersonal();

            TransActivoDetalles = new List<TransferenciaActivoDetalleModel>();

            toDelete = new List<TransferenciaActivoDetalleModel>();

        }

        public TransferenciaActivoModel(TransferenciaActivosBE transActivo)
        {
            TransActivo = transActivo;
            ID = Guid.NewGuid();

            PersonalGestiona = listaPersonal();
            PersonalResponsable = listaPersonal();

            TransActivoDetalles = new List<TransferenciaActivoDetalleModel>();

            toDelete = new List<TransferenciaActivoDetalleModel>();

        }

        public SelectList listaPersonal()
        {
            personal.IDEmp = 1;
            personal.IDOrigen = 27;
            personal.OrigenPers = 1;
            List<SelectListItem> listItem = new List<SelectListItem>();

            listItem.Add(seleccione);
            listItem.AddRange(new SelectList(service.ListarPersonal(personal), "IDPersonal", "NomsPers"));


            return new SelectList(listItem, "Value", "Text");
        }


        
    }
}
